
/*
 * Copyright (C) 2008-2009 Archie L. Cobbs. All rights reserved.
 *
 * $Id: Marker.java 377 2010-03-11 20:50:18Z archie.cobbs $
 */

package org.dellroad.sidekar.gc;

import org.dellroad.sidekar.Item;

/**
 * Tracks which items have been seen during a garbage collection run.
 */
public interface Marker {

    /**
     * Reset this instance. All items should be marked as having not been seen.
     * This method is invoked at the start of a garbage collection.
     */
    void reset();

    /**
     * Determine if the given item has been previously marked as having been seen.
     *
     * @param item item to determine whether seen
     * @throws NullPointerException if {@code item} is {@code null}
     */
    boolean isMarked(Item<?> item);

    /**
     * Mark a previously unseen item as having been seen.
     *
     * @param item item to mark as having been seen
     * @throws NullPointerException if {@code item} is {@code null}
     */
    void mark(Item<?> item);

    /**
     * Close down this instance. This is invoked after garbage collection completes (normally or abnormally).
     * It should release any temporary resources associated with this instance.
     */
    void close();
}

